package com.xiaokai.domain.strategy.model.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * Author:yang
 * Date:2024-08-24 11:21
 * 策略实体类
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StrategyEntity {
    private Integer strategyId;

    private String strategyDesc;

    private String ruleModels;

    // rule_blacklist,rule_weight
    public String[] ruleModels() {
        if (StringUtils.isBlank(ruleModels)) return null;
        return ruleModels.split(",");
    }

    public String getRuleWeight() {
        String[] ruledModels = this.ruleModels();
        if (null == ruleModels) return null;
        for (String ruledModel : ruledModels) {
            if (Objects.equals("rule_weight", ruledModel)) return ruledModel;
        }
        return null;
    }

}
